/**
 * Free software.
 */

package org.nanhill.moo.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.nanhill.commons.lang.StringKit;
import org.nanhill.moo.domain.User;
import org.nanhill.moo.service.UserService;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author alin [xalinx at gmail dot com]
 * @date 2006-11-3
 */
public class UserInfoController extends SimpleViewController {

	private UserService userService;

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	protected ModelAndView handleContinueRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String attr = request.getParameter("userId");
		if (attr != null || StringKit.isDigit(attr)) {
			long uid = Long.parseLong(attr);
			User user = userService.loadById(uid);
			return new ModelAndView(this.getFirstView(), "user", user);
		}
		return null;
	};

}
